[Apache] mod_rewrite www.site.com/dir/ --> www.site.com/dir/2009/
Posted
by Casey
on Server Fault
See other posts from Server Fault
or by Casey
Published on 2010-06-04T23:34:55Z
Indexed on
2010/06/05
6:23 UTC
Read the original article
Hit count: 459
apache
|mod-rewrite
I'm having trouble with this rewrite. I've never really used mod_rewrite before and don't have much experience with regex. Any help is appreciated!
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
#prevent nested looping
RewriteCond %{ENV:REDIRECT_STATUS} ^$
#re-route incoming requests
RewriteRule ^(.*)$ %{REQUEST_URI}2009/$1 [L,NE]
</IfModule>
This partially works, http://www.site.com/dir/ is routed to http://www.site.com/dir/2009/ but a request like http://www.site.com/dir/css/theme.css fails. I'm hoping to rewrite all requests to the parent directory into the 2009 subdirectory but I keep encountering infinite loops and server errors messages. I haven't found any useful examples out there. I figured this would be a common rewrite...
Thanks in advance!
© Server Fault or respective owner